#pragma once
#include "Control.h"
class Widget : public Control
{
public:
	template<typename T>
	struct Para
	{
		int idx;
		T v;
		T min;
		T max;
		Para() {}
		Para(T _max, T _min, T _v)
		{
			v = _v;
			max = _max;
			min = _min;
		}
	};

	Widget() {}
	~Widget() {}

	tstring GetClassName() override;
	bool OnInit() override;
	void OnDestroy() override;
	void OnDraw() override;
	void Resize(int w, int h) override;
	void Create(Window* window, vec2 pos, vec2 size, UINT32 id) override;
	void AddPara(std::string name, double v, double min, double max)
	{
		//paras[name] = Para<double>(max,min,v);
		Para<double> p;
		p.v = v;
		p.min = min;
		p.max = max;
		p.idx = idx++;
		paras[name] = p;
	}
	void ParseXmlElement(TiXmlElement* ele);
	void ParseAttribute(TiXmlElement* ele);
private:
	void DrawItem(const Para<double>& item);
	virtual bool SetAttribute(const char* attrName, const char* attrVal);
	//std::vector<std::tuple<std::string, double, double, double>> paras;
	std::map<std::string, Para<double>> paras;
	int idx{0};
};